cmake_minimum_required(VERSION 3.15)

set(TARGET_NAME "runtime_cu")
set(LIB_NAME "lib${TARGET_NAME}.so")
project(${TARGET_NAME})

message(STATUS "CMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}" )
message(STATUS "MACA_PATH=${MACA_PATH}" )
set(MACA_INC_PATH "${MACA_PATH}/include" )
set(MACA_COMMON_INC_PATH "${MACA_PATH}/include/common" )
set(MCR_INC_PATH "${MACA_PATH}/include/mcr" )
set(MCLOG_INC_PATH "${MACA_PATH}/include/mclog" )

set(RUNTIME_WRAPPER_SRC
    ${CMAKE_CURRENT_SOURCE_DIR}/src/cuda_driver_wrapper.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/src/cuda_runtime_wrapper.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/src/cuda_wrapper_internal_symbol.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/src/nvrtc_wrapper.cpp)
link_directories( ${MACA_PATH}/lib )
add_library(${TARGET_NAME} SHARED ${RUNTIME_WRAPPER_SRC})

target_link_libraries( ${TARGET_NAME} PRIVATE mcruntime)

target_include_directories(${TARGET_NAME}
    PRIVATE
        ${MACA_INC_PATH}
        ${MCR_INC_PATH}
        ${MCLOG_INC_PATH}
        ${MACA_COMMON_INC_PATH}
        ${CMAKE_CURRENT_SOURCE_DIR}/include
    PUBLIC
        ${CMAKE_SOURCE_DIR}/include/bridge/runtime)

install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${LIB_NAME} DESTINATION ${LIB_DEST_DIR})

